package com.netty.java.test;

import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

@Slf4j
public class MyServer {

    private static final Integer PORT = 10086;

    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(8888);

        Socket accept = serverSocket.accept();

        BufferedReader reader = new BufferedReader(new InputStreamReader(accept.getInputStream()));

        String message = reader.readLine();

        log.info("My Server Received message:[{}]", message);

        String replayMessage = "hello client";

        log.info("My Server replay message is [{}]", replayMessage);

        OutputStream os = accept.getOutputStream();

        PrintWriter writer = new PrintWriter(os);

        writer.write(replayMessage);

        writer.flush();

        os.close();

        reader.close();

        serverSocket.close();
    }


}
